<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<script type="text/javascript" src="<c:url value="/layout/javascript/largePaginator.js"/>">/**/</script>
<script type="text/javascript" src="<c:url value="/layout/javascript/jquery.form.js"/>">/**/</script> 
<script type="text/javascript" src="<c:url value="/layout/javascript/form.js"/>">/**/</script>
<script type="text/javascript">
$(document).ready(function() {
	var options = { 
	    //target:        '#hiddenresult', 
	    beforeSubmit:  function () {
	                       $('#Searchresult').empty();
	                       $('#Searchresult').html('<img alt="<bean:message key="wait.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="wait.message"/>');
	                   }, 
	    success:       function (data) {
				            var identity = data.slice(0,68);
				            // Riceve come risposta il box di errore di validazione
				            if (identity.search('#boxvalidation') != -1) {
				                $('#validationbox').html(data);
				                $('#Searchresult').empty();
				            } else { // Riceve la lista di ticket
				            	$('#hiddenresult').html(data);
				                	var id = '';
				            		$('#hiddenresult select').each(function() {
				            			id = $(this).attr("id");
				            			id = id.slice(id.indexOf("-")+1);
				            			testChangeDeviceSelect(id);
				            		});
				               
				               paginateDeviceHistory();
				            }
				       },
	    error:         function () {
	                	   showErrorDialog('#dialog', 
	                			    { msg: "<bean:message key="device.history.form.msg" bundle="errors"/>",
	                		          boxTitle: "<bean:message key="device.history.form.boxTitle" bundle="errors"/>",
	                		          msgStatus: "<bean:message key="device.history.form.msgStatus" bundle="errors"/>" });
        }
	                   
	};

    $('#form_managedevice').ajaxForm(options);
    $('#form_managedevice').submit();
});
</script>

<div id="content">
		<!--FORM-->
		<fieldset id="fieldset">
			<legend class="fieldsetLabel"><bean:message key="device.manage" bundle="device"/></legend>
				
			<div id="form_containerTH">

				<html:form styleId="form_managedevice" styleClass="appnitro"  action="/operator/getdevicelist.do">
				<div id="divDevice">	
					<ul id="ulDevice">
					<li id="li_1DeviceForm" >
						<label class="description" for="deviceType"><bean:message key="device.type" bundle="device"/></label>
						<div>
							<html:select property="deviceType" styleClass="element select medium" styleId="deviceType">
                                <option  selected="selected" value=""><bean:message key="select.option.alls"/></option>
                                <html:options name="devices" />
                            </html:select>
						</div> 
					</li>
					<li id="li_2DeviceForm" >
						<label class="description" for="users"><bean:message key="device.users" bundle="device"/></label>
						<div>
							<html:select property="userID" styleClass="element select large" styleId="users">
                                <option  selected="selected" value=""><bean:message key="select.option.alls"/></option>
                                <html:options collection="users" property="userID" labelProperty="username" />
                            </html:select>
						</div> 
					</li>
					<li id="li_3DeviceForm" >
						<label class="description" for="offices"><bean:message key="device.offices" bundle="device"/></label>
						<div>
							<html:select property="officeID" styleClass="element select medium" styleId="offices">
                                <option  selected="selected" value=""><bean:message key="select.option.alls"/></option>
                                <html:options collection="offices" property="officeID" labelProperty="number" />
                            </html:select>
						</div> 
					</li>
					<li id="buttonsDevice">
						<html:submit styleId="searchButton" styleClass="button_text">
						 <bean:message key="button.search"/>
						</html:submit>
					</li>
					</ul>
				</div>	
				</html:form>	
				
				<div id="ListHistory">
					<div id="Pagination" class="pagination"> </div>
					<br style="clear:both;" />
					<ul id="label">
                        <li class="labelAssignedTo"><bean:message key="device.assignedto" bundle="device"/></li>
                        <li class="labelDeviceName"><bean:message key="device.devicename" bundle="device"/></li>
                        <li class="labelDeviceModel"><bean:message key="device.devicemodel" bundle="device"/></li>
                        <li class="labelVendor"><bean:message key="device.devicevendor" bundle="device"/></li>
                        <li class="labelReadC"><bean:message key="device.devicefeatures" bundle="device"/></li>
                        <li class="labelAssignedOffice"><bean:message key="device.assignedoffice" bundle="device"/></li>
                    </ul>
					<div id="Searchresult">
						<img alt="<bean:message key="wait.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="wait.message"/>
					</div>
			        
			        <!-- Container element for all the Elements that are to be paginated -->
			        <div id="hiddenresult" style="display:none;">
			        </div>
				</div>
			</div>	
		</fieldset>
</div>	
